package com.gzhu.knowledgeAdmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gzhu.knowledgeAdmin.entity.TDxjgT;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface TDxjgTMapper extends BaseMapper<TDxjgT> {

    @Select("<script>" +
            "SELECT " +
            "    j.F_KHSJHM AS fkhsjhm," +
            "    j.F_ID AS fid," +
            "    j.F_KHSJHMMD5 AS fkhsjhmmd5," +
            "    m.F_DXLX AS fdxlx," +
            "    m.F_MBMC AS fdxmb," +
            "    j.F_DRLX AS fdrlx," +
            "    j.F_FSLX AS ffslx," +
            "    j.F_WHRW AS fwhrw," +
            "    j.F_JXZT AS fjxzt," +
            "    j.F_BZ AS fbz," +
            "    j.F_DXFSSJ AS fdxfssj," +
            "    j.F_DXTJSJ AS fdxtjsj," +
            "    j.F_SBYY AS fsbyy " +
            "FROM t_dxjg_t j " +
            "JOIN t_dxmb_t m ON j.F_DXMBID = m.F_ID " +
            "<where>" +
            "  <if test='fkhsjhm != null and fkhsjhm != \"\"'> j.F_KHSJHM = #{fkhsjhm} </if>" +
            "  <if test='fid != null and fid != \"\"'> AND j.F_ID = #{fid} </if>" +
            "  <if test='fkhsjhmmd5 != null and fkhsjhmmd5 != \"\"'> AND j.F_KHSJHMMD5 = #{fkhsjhmmd5} </if>" +
            "  <if test='fdxlx != null and fdxlx != \"\"'> AND m.F_DXLX = #{fdxlx} </if>" +
            "  <if test='fdxmb != null and fdxmb != \"\"'> AND m.F_MBMC = #{fdxmb} </if>" +
            "  <if test='fdrlx != null and fdrlx != \"\"'> AND j.F_DRLX = #{fdrlx} </if>" +
            "  <if test='ffslx != null and ffslx != \"\"'> AND j.F_FSLX = #{ffslx} </if>" +
            "  <if test='fwhrw != null and fwhrw != \"\"'> AND j.F_WHRW = #{fwhrw} </if>" +
            "  <if test='fjxzt != null and fjxzt != \"\"'> AND j.F_JXZT = #{fjxzt} </if>" +
            "  <if test='fdxtjsjStart != null and fdxtjsjEnd != null'>" +
            "    AND j.F_DXTJSJ BETWEEN #{fdxtjsjStart} AND #{fdxtjsjEnd} </if>" +
            "  <if test='fdxSubmitStart != null and fdxSubmitEnd != null'>" +
            "    AND j.F_DXFSSJ BETWEEN #{fdxSubmitStart} AND #{fdxSubmitEnd} </if>" +
            "  <if test='fdxSendStart != null and fdxSendEnd != null'>" +
            "    AND j.F_DXFSSJ BETWEEN #{fdxSendStart} AND #{fdxSendEnd} </if>" +
            "</where>" +
            "</script>")
    List<Map<String, Object>> customJoinQuery(
            @Param("fkhsjhm") String fkhsjhm,
            @Param("fid") String fid,
            @Param("fkhsjhmmd5") String fkhsjhmmd5,
            @Param("fdxlx") String fdxlx,
            @Param("fdxmb") String fdxmb,
            @Param("fdrlx") String fdrlx,
            @Param("ffslx") String ffslx,
            @Param("fwhrw") String fwhrw,
            @Param("fjxzt") String fjxzt,
            @Param("fdxtjsjStart") String fdxtjsjStart,
            @Param("fdxtjsjEnd") String fdxtjsjEnd,
            @Param("fdxSubmitStart") String fdxSubmitStart,
            @Param("fdxSubmitEnd") String fdxSubmitEnd,
            @Param("fdxSendStart") String fdxSendStart,
            @Param("fdxSendEnd") String fdxSendEnd
    );

}

